const { log } = require('console')
const fs = require('fs')
const path = require('path')

function readFile(arg) {
  return new Promise((resolve, reject) => {
    let mypath = path.join(__dirname, `../assets/${arg}.txt`)
    // 异步函数
    fs.readFile(mypath, (err, data) => {
      if (err) throw reject(err)
      // console.log(data.toString()) // 这里读取的文件是二进制留，因此要转字符串
      resolve(data.toString())
    })
  })

}

let vueText = readFile('vue')
let reactText = readFile('react')
let angularText = readFile('angular')



// 执行命令 node ./utils/readfile.js 打印出vue文本